<?php $__env->startSection('content'); ?>
    <?php
    use \App\Models\Enum\MailStatus;
    use \App\Models\Enum\MailType;
    ?>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-title">
                <h5>邮件发送</h5>
            </div>
            <div class="ibox-content">
                <?php echo $__env->make('widget.refresh', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                <a href="<?php echo e(route('mail.create')); ?>" link-url="javascript:void(0)">
                    <button class="btn btn-primary btn-sm" type="button"><i class="fa fa-plus-circle"></i> 添加邮件
                    </button>
                </a>
                <a href="<?php echo e(route('mail.batchCreate')); ?>" link-url="javascript:void(0)">
                    <button class="btn btn-primary btn-sm" type="button"><i class="fa fa-plus-circle"></i> 添加批量邮件
                    </button>
                </a>
                <form class="form-horizontal " action="<?php echo e(route('mail.index')); ?>" method="post"
                      enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>

                    <input type="hidden" name="page_size" value="<?php echo e(old('page_size')); ?>"/>
                </form>
                <table class="table table-striped table-bordered table-hover m-t-md tblData">
                    <thead>
                    <tr>
                        
                        <th class="text-center">ID</th>
                        <th class="text-center">渠道</th>
                        <th class="text-center">服务器</th>
                        <th style="width: 10%" class="text-center">标题</th>
                        <th style="width: 15%" class="text-center">内容</th>
                        <th style="width: 15%" class="text-center">发放理由</th>
                        <th class="text-center">附件</th>
                        <th class="text-center">邮件类型</th>
                        <th class="text-center">目标玩家</th>
                        <th class="text-center">管理员</th>
                        <th class="text-center">编辑时间</th>
                        <th class="text-center">状态</th>
                        <th class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody class="text-center" id="tbContainer">
                    <?php $__currentLoopData = $mails; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr data-id="<?php echo e($item['id']); ?>">
                            
                            <td><?php echo e($item['id']); ?></td>
                            <td><?php echo e($item->channel->channel_name); ?></td>
                            <td><?php echo isset($item->server->server_name) ? $item->server->server_name : ''?></td>
                            <td><?php echo e($item['title']); ?></td>
                            <td><?php echo e(str_replace('%5Cn', "\\n", $item['content'])); ?></td>
                            <td><?php echo e($item['reason']); ?></td>
                            <td>
                                <?php
                                if ($item->mail_type == MailType::BATCH) {
                                    echo "<a href='{$item['attachment']}' target='_blank'>下载附件</a>";
                                } else {
                                    echo $item['attachment'];
                                }
                                ?>
                            </td>
                            <td><?php echo e(MailType::get($item['mail_type'])); ?></td>
                            <td><?php echo e($item['nickname']); ?></td>
                            <td><?php if (isset($item->approver->name)) echo $item->approver->name;?></td>
                            <td><?php echo e($item['updated_at']); ?></td>
                            <td>
                                <?php
                                switch ($item['status']) {
                                    case MailStatus::UNCHECK:
                                        echo '<span class="label label-primary">' . MailStatus::get(MailStatus::UNCHECK) . '</span>';
                                        break;
                                    case MailStatus::CHECKING:
                                        echo '<span class="label label-info">' . MailStatus::get(MailStatus::CHECKING) . '</span>';
                                        break;
                                    case MailStatus::AGREE:
                                        echo '<span class="label label-success">' . MailStatus::get(MailStatus::AGREE) . '</span>';
                                        break;
                                    case MailStatus::BAN:
                                        echo '<span class="label label-danger">' . MailStatus::get(MailStatus::BAN) . '</span>';
                                        break;
                                    case MailStatus::CANCEL:
                                        echo '<span class="label label-warning">' . MailStatus::get(MailStatus::CANCEL) . '</span>';
                                        break;
                                    default:
                                        echo '未定义状态';
                                }
                                ?>
                            </td>
                            <td>
                                <?php
                                if ($item['status'] == MailStatus::UNCHECK) {
                                    $checkHref = route('mail.status', ['status' => MailStatus::CHECKING, 'id' => $item->id]);
                                    $cancelHref = route('mail.status', ['status' => MailStatus::CANCEL, 'id' => $item->id]);
                                    echo <<< EOF
                                <a href="$checkHref"><button type="button" class="btn btn-xs btn-info">提交审核</button></a>
                                <a href="$cancelHref"><button type="button" class="btn btn-xs btn-warning">撤销</button></a>
EOF;


                                }
                                ?>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
                <div class="pull-left pagination m-t-no">
                    <?php echo $__env->make('widget.page',['reqPageSize'=>$reqPageSize], array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                </div>
                <div class="pull-right pagination m-t-no">
                    <div class="text-center">
                        <?php
                        if (count($mails) > 0) {
                            echo $mails->appends(['page_size' => app('request')->input('page_size')])->links();
                        }
                        ?>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
    <script>
    </script>
    <link href="<?php echo e(loadEdition('/admin/css/plugins/datapicker/bootstrap-datepicker.css')); ?>" rel="stylesheet">
    <link href="<?php echo e(loadEdition('/admin/js/plugins/bootstrap-table/bootstrap-table.min.css')); ?>" rel="stylesheet">
    <link href="<?php echo e(loadEdition('/js/plugins/chosen_v1.8.7/chosen.min.css')); ?>" rel="stylesheet">

<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
    <!--bootstrap-datepicker start-->
    <script src="<?php echo e(loadEdition('/admin/js/plugins/datapicker/bootstrap-datepicker.js')); ?>"></script>
    <script src="<?php echo e(loadEdition('/admin/js/plugins/datapicker/bootstrap-datepicker.zh-CN.js')); ?>"></script>
    <!--bootstrap-datepicker end-->
    <!--bootstrap-table start-->
    <script src="<?php echo e(loadEdition('/admin/js/plugins/bootstrap-table/bootstrap-table.min.js')); ?>"></script>
    <script src="<?php echo e(loadEdition('/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js')); ?>"></script>
    <!--bootstrap-table end-->
    <!--chosen-->
    <script src="<?php echo e(loadEdition('/js/plugins/chosen_v1.8.7/chosen.jquery.min.js')); ?>"></script>
    <script src="<?php echo e(loadEdition('/js/plugins/chosen_v1.8.7/chosen.proto.min.js')); ?>"></script>
    <script src="<?php echo e(loadEdition('/js/global.js')); ?>"></script>
    <script>
        $(document).ready(function () {

        });
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>